@echo off

set msBuildDir="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin"
set Platform=AnyCPU
set buildType=Release
set returnErrorCode=true
set pause=true
if /i "%1"=="/q" (
 set pause=false
)
if /i "%2"=="/d" (
 set buildType=Debug
)

@ECHO ----------------------------------------
@ECHO Building Sidvall Started
@ECHO ----------------------------------------
@ECHO.

call "..\..\.nuget\nuget.exe" restore "..\..\Sidvall.Build.sln"
call %msBuildDir%\msbuild "..\..\Sidvall.Build.sln" /t:Rebuild /p:Configuration=%buildType% /p:Platform="Any CPU" /verbosity:q
@if errorlevel 1 goto :error

@ECHO.
@ECHO ----------------------------------------
@ECHO Building Sidvall Completed
@ECHO ----------------------------------------
@ECHO.

@goto :exit



:error
if %returnErrorCode%==false goto exit

@ECHO An error occured - %errorLevel%
PAUSE
@exit errorLevel



:exit
if %pause%==true PAUSE

